home *** CD-ROM | disk | FTP | other *** search
/ HP Idea Kits: Let's Celebrate / PHOTODLX.ISO / extras / diamar / photo.dxr / 00004_general handlers 1.ls < prev    next >
Encoding:
Text File  |  1996-04-22  |  8.2 KB  |  281 lines

  1. on loadScreenData screen
  2.   global gCurrentScreen, gCurrentStyle, gCurrentPalette, gScreenList, gWorkshopRecord, gLastScreen, gLastStyle, gLastPalette, gCurrentDatabase, gJumpHome
  3.   cursor(4)
  4.   if screen = "SCN0002" then
  5.     set screen to gJumpHome
  6.   end if
  7.   set gLastScreen to gCurrentScreen
  8.   set gLastStyle to gCurrentStyle
  9.   set gLastPalette to gCurrentPalette
  10.   set screenNumber to value(char 4 to 7 of screen)
  11.   set databaseSection to integer(screenNumber / 100)
  12.   set lineNumber to screenNumber - (databaseSection * 100) + 1
  13.   set databasePointer to gCurrentDatabase + databaseSection
  14.   set screenData to line lineNumber of field databasePointer
  15.   set gCurrentScreen to item 1 of screenData
  16.   set gCurrentStyle to item 2 of screenData
  17.   set whichPalette to integer(item 3 of screenData)
  18.   set gScreenList to list(EMPTY)
  19.   set itemCounter to 4
  20.   repeat while itemCounter <= the number of items in screenData
  21.     set listPosition to item itemCounter of screenData
  22.     set listValue to item itemCounter + 1 of screenData
  23.     if listPosition = 1 then
  24.       set gJumpHome to listValue
  25.     else
  26.       if listPosition = 18 then
  27.         set menuNumber to integer(listValue)
  28.       else
  29.         if listPosition = 19 then
  30.           set menuItem to integer(listValue)
  31.           put "1" into item menuItem * 2 of line menuNumber of field gWorkshopRecord
  32.         else
  33.           if (char 1 of listValue = "S") or (char 1 of listValue = "P") then
  34.             setAt(gScreenList, value(listPosition), listValue)
  35.           else
  36.             setAt(gScreenList, value(listPosition), integer(listValue))
  37.           end if
  38.         end if
  39.       end if
  40.     end if
  41.     set itemCounter to itemCounter + 2
  42.   end repeat
  43.   set palCast to getAt(gScreenList, whichPalette)
  44.   if palCast = -1 then
  45.     set palCast to 209
  46.   end if
  47.   set gCurrentPalette to the palette of cast palCast
  48. end
  49.  
  50. on puppetState startSprite, endSprite, state
  51.   set spriteCounter to startSprite
  52.   repeat while spriteCounter <= endSprite
  53.     if the puppet of sprite spriteCounter <> state then
  54.       puppetSprite(spriteCounter, state)
  55.     end if
  56.     set spriteCounter to spriteCounter + 1
  57.   end repeat
  58. end
  59.  
  60. on spriteVisible startSprite, endSprite, state
  61.   set spriteCounter to startSprite
  62.   repeat while spriteCounter <= endSprite
  63.     if the visible of sprite spriteCounter <> state then
  64.       set the visible of sprite spriteCounter to state
  65.     end if
  66.     set spriteCounter to spriteCounter + 1
  67.   end repeat
  68. end
  69.  
  70. on replaceSprite startSprite, endSprite, update
  71.   global gScreenList
  72.   repeat with spriteCounter = startSprite to endSprite
  73.     set castNumber to getAt(gScreenList, spriteCounter)
  74.     if (castNumber <> 0) and (the castNum of sprite spriteCounter <> castNumber) then
  75.       set the castNum of sprite spriteCounter to castNumber
  76.       if update = 1 then
  77.         updateStage()
  78.       end if
  79.     end if
  80.   end repeat
  81.   if update = 2 then
  82.     updateStage()
  83.   end if
  84.   updateStage()
  85. end
  86.  
  87. on soundMoreText
  88.   global gScreenList, gBTN041U, gBTN042U
  89.   if getAt(gScreenList, 27) <> 0 then
  90.     set the castNum of sprite 27 to gBTN041U
  91.   end if
  92.   if getAt(gScreenList, 28) <> 0 then
  93.     set the castNum of sprite 28 to gBTN042U
  94.   end if
  95. end
  96.  
  97. on paletteSwap
  98.   global gPaletteSwapping, gLastPalette, gCurrentPalette
  99.   if gPaletteSwapping = 0 then
  100.     exit
  101.   end if
  102.   if gLastPalette <> gCurrentPalette then
  103.     puppetPalette(gCurrentPalette, 60)
  104.   end if
  105.   updateStage()
  106. end
  107.  
  108. on upDownToggle
  109.   global gSpriteNumber, gValid, gOffsetBtnU, gOffsetBtnD, gOffsetBtnG, gDUMMY_G
  110.   cursor(4)
  111.   set castNumber to the castNum of sprite gSpriteNumber
  112.   if (castNumber >= gOffsetBtnD) and (castNumber < gOffsetBtnU) then
  113.     set castNumber to castNumber - gOffsetBtnD + gOffsetBtnU
  114.     set the castNum of sprite gSpriteNumber to castNumber
  115.     set gValid to 1
  116.   else
  117.     if (castNumber >= gOffsetBtnU) and (castNumber < gOffsetBtnG) then
  118.       set castNumber to castNumber - gOffsetBtnU + gOffsetBtnD
  119.       set the castNum of sprite gSpriteNumber to castNumber
  120.       set gValid to 1
  121.     else
  122.       if (castNumber >= gOffsetBtnG) or (castNumber = gDUMMY_G) then
  123.         set gValid to 0
  124.       end if
  125.     end if
  126.   end if
  127.   updateStage()
  128.   cursor(-1)
  129. end
  130.  
  131. on jump
  132.   global gJumpFlag, gCurrentStyle, gLastPalette, gPaletteSwapping
  133.   set gJumpFlag to 0
  134.   if gPaletteSwapping then
  135.     puppetPalette(gLastPalette, 60)
  136.   end if
  137.   go(gCurrentStyle)
  138. end
  139.  
  140. on jumpButton
  141.   global gSpriteNumber, gJumpToScreen, gJumpFlag, gScreenList
  142.   set gJumpFlag to 1
  143.   set gJumpToScreen to getAt(gScreenList, gSpriteNumber + 50)
  144. end
  145.  
  146. on popUpMouseDown
  147.   global gSpriteNumber
  148.   set gSpriteNumber to the clickOn
  149.   if (gSpriteNumber >= 29) and (gSpriteNumber <= 48) then
  150.     upDownToggle()
  151.   end if
  152. end
  153.  
  154. on popUpMouseUp
  155.   global gSpriteNumber, gValid, gBookMarkCast
  156.   if (gSpriteNumber >= 29) and (gSpriteNumber <= 48) and (gValid = 1) then
  157.     if the castNum of sprite gSpriteNumber = gBookMarkCast then
  158.       handleBookMark()
  159.       exit
  160.     end if
  161.     upDownToggle()
  162.     popUpMenu(0)
  163.     jumpButton()
  164.   else
  165.     popUpMenu(0)
  166.   end if
  167. end
  168.  
  169. on popUpMenu state
  170.   global gActivePopUp, gLastMouseDownScript, gLastMouseUpScript, gPopUpState, gOffsetBtnD, gOffsetBtnU
  171.   cursor(4)
  172.   if gActivePopUp = 2 then
  173.     popUpMenuVisible(29, 33, state)
  174.   else
  175.     if gActivePopUp = 3 then
  176.       popUpMenuVisible(34, 39, state)
  177.     else
  178.       if gActivePopUp = 4 then
  179.         popUpMenuVisible(40, 40, state)
  180.       else
  181.         if (gActivePopUp = 8) or (gActivePopUp = 13) then
  182.           popUpMenuVisible(44, 47, state)
  183.         end if
  184.       end if
  185.     end if
  186.   end if
  187.   set gPopUpState to state
  188.   if state = 1 then
  189.     saveMouseScripts()
  190.     set the mouseDownScript to "popUpMouseDown"
  191.     set the mouseUpScript to "popUpMouseUp"
  192.   else
  193.     set castNumber to the castNum of sprite gActivePopUp
  194.     set the castNum of sprite gActivePopUp to castNumber - gOffsetBtnD + gOffsetBtnU
  195.     restoreMouseScripts()
  196.   end if
  197.   updateStage()
  198.   cursor(-1)
  199. end
  200.  
  201. on popUpMenuVisible startSprite, endSprite, state
  202.   global gScreenList, gDUMMY_G, gOffsetBtnD, gOffsetBtnU
  203.   repeat with spriteCounter = startSprite to endSprite
  204.     set castNumber to getAt(gScreenList, spriteCounter)
  205.     if castNumber <> 0 then
  206.       if state = 0 then
  207.         set the castNum of sprite spriteCounter to gDUMMY_G
  208.         next repeat
  209.       end if
  210.       set the castNum of sprite spriteCounter to castNumber
  211.     end if
  212.   end repeat
  213. end
  214.  
  215. on preLoadScreenData
  216.   global gReadAhead, gScreenList, gStyleData, gCurrentDatabase, gStyle8Cast
  217.   if gReadAhead = 0 then
  218.     exit
  219.   end if
  220.   set screen to getAt(gScreenList, 55)
  221.   set screenNumber to value(char 4 to 7 of screen)
  222.   if screenNumber = 2 then
  223.     exit
  224.   end if
  225.   set databaseSection to integer(screenNumber / 100)
  226.   set lineNumber to screenNumber - (databaseSection * 100) + 1
  227.   set databasePointer to gCurrentDatabase + databaseSection
  228.   set screenData to line lineNumber of field databasePointer
  229.   set style to value(char 4 to 7 of item 2 of screenData)
  230.   set styleCastNum to getAt(gStyleData, style)
  231.   if styleCastNum = 0 then
  232.     exit
  233.   end if
  234.   preLoadCast(styleCastNum)
  235.   set itemCounter to 4
  236.   repeat while itemCounter <= the number of items in screenData
  237.     set listPosition to item itemCounter of screenData
  238.     set listValue to integer(item itemCounter + 1 of screenData)
  239.     if (listPosition = 12) or ((listPosition = 9) and (styleCastNum = gStyle8Cast)) then
  240.       preLoadCast(listValue)
  241.     else
  242.       if listPosition > 12 then
  243.         exit
  244.       end if
  245.     end if
  246.     set itemCounter to itemCounter + 2
  247.   end repeat
  248. end
  249.  
  250. on loadPreLoadDatabase
  251.   global gPreLoadDatabase, gStyleData
  252.   set itemCounter to 1
  253.   repeat while itemCounter <= the number of items in field gPreLoadDatabase
  254.     set listPosition to item itemCounter of field gPreLoadDatabase
  255.     set listValue to item itemCounter + 1 of field gPreLoadDatabase
  256.     setAt(gStyleData, integer(listPosition), integer(listValue))
  257.     set itemCounter to itemCounter + 2
  258.   end repeat
  259. end
  260.  
  261. on SoundInterrupt style, which
  262.   global gCurrentStyle
  263.   if (which = 9) or (which = 24) or (which = 25) or (which = 28) then
  264.     return 0
  265.   else
  266.     if (style = 3) and (which = 13) then
  267.       return 0
  268.     else
  269.       if (style = 5) and ((which >= 13) and (which <= 16)) then
  270.         return 0
  271.       else
  272.         if (style = 7) and ((which >= 13) and (which <= 16)) then
  273.           return 0
  274.         else
  275.           return 1
  276.         end if
  277.       end if
  278.     end if
  279.   end if
  280. end
  281.